/*
 * @Author: 蔡继周
 * @Date: 2021-11-21 02:40:38
 * @LastEditTime: 2021-11-21 02:40:38
 * @LastEditors: 蔡继周
 * @Description:validate.js
 */
const checkEmail = (rule, value, cb) => {
    const regEmail = /^\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/;
    if (regEmail.test(value)) {
        return cb();
    }
    // 返回错误提示
    cb(new Error("请输入正确的邮箱"));
};

const checkPhone = (rule, value, callback) => {
    const reg = /^[1][3,4,5,7,8][0-9]{9}$/;
    if (value == '' || value == undefined || value == null) {
        callback();
    } else {
        if ((!reg.test(value)) && value != '') {
            callback(new Error('请输入正确的电话号码'));
        } else {
            callback();
        }
    }
}

export {
    checkEmail,
    checkPhone
}